#include "Cube1.h"
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCubeSource.h>
#include <vtkNamedColors.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkNew.h>
#include <vtkProperty.h>

Cube1::Cube1(QWidget* parent)
	: QMainWindow(parent)
{
	this->resize(600, 400);
	vtkNew<vtkNamedColors> colors;

	// Create a rendering window and renderer.
	vtkNew<vtkRenderer> ren;

	// Create a cube.
	vtkNew<vtkCubeSource> cube;
	cube->Update();

	// mapper
	vtkNew<vtkPolyDataMapper> cubeMapper;
	cubeMapper->SetInputData(cube->GetOutput());

	// Actor.
	vtkNew<vtkActor> cubeActor;
	cubeActor->SetMapper(cubeMapper);
	cubeActor->GetProperty()->SetColor(colors->GetColor3d("Banana").GetData());

	// Assign actor to the renderer.
	ren->AddActor(cubeActor);

	ren->ResetCamera();
	ren->GetActiveCamera()->Azimuth(30);
	ren->GetActiveCamera()->Elevation(30);
	ren->ResetCameraClippingRange();
	ren->SetBackground(colors->GetColor3d("Silver").GetData());

	vtkWidget = new QVTKOpenGLNativeWidget(this);
	vtkWidget->renderWindow()->AddRenderer(ren);
	this->setCentralWidget(vtkWidget);

}
